package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CmsHonorAward;
import com.ruoyi.system.service.ICmsHonorAwardService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/cms/honor")
public class CmsHonorAwardController extends BaseController {

    @Resource
    private ICmsHonorAwardService cmsHonorAwardService;

    @GetMapping("/list")
    public TableDataInfo list(CmsHonorAward honor) {
        startPage();
        List<CmsHonorAward> list = cmsHonorAwardService.selectCmsHonorAwardList(honor);
        return getDataTable(list);
    }

    @GetMapping("/{honorId}")
    public AjaxResult getInfo(@PathVariable Long honorId) {
        return AjaxResult.success(cmsHonorAwardService.selectCmsHonorAwardById(honorId));
    }

    @Log(title = "荣誉奖励", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmsHonorAward honor) {
        return toAjax(cmsHonorAwardService.insertCmsHonorAward(honor));
    }

    @Log(title = "荣誉奖励", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmsHonorAward honor) {
        return toAjax(cmsHonorAwardService.updateCmsHonorAward(honor));
    }

    @Log(title = "荣誉奖励", businessType = BusinessType.DELETE)
    @DeleteMapping("/{honorIds}")
    public AjaxResult remove(@PathVariable Long[] honorIds) {
        return toAjax(cmsHonorAwardService.deleteCmsHonorAwardByIds(honorIds));
    }
}


